home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / term / term_47a_pch.lha / Source / gtlayout-38.3 / LTP_DrawGroup.c < prev    next >
C/C++ Source or Header  |  1996-11-12  |  7KB  |  317 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. VOID
  15. LTP_DrawObjectLabel(LayoutHandle *Handle,ObjectNode *Node)
  16. {
  17.     if(Node->Label)
  18.     {
  19.         LONG Left,Top,GlyphHeight = Handle->GlyphHeight;
  20.  
  21.         switch(Node->LabelPlace)
  22.         {
  23.             case PLACE_LEFT:
  24.  
  25.                 Left    = Node->Left;
  26.                 Top        = Node->Top + (Node->Height - GlyphHeight) / 2;
  27.  
  28.                 break;
  29.  
  30.             case PLACE_RIGHT:
  31.  
  32.                 Left    = Node->Left + Node->Width + INTERWIDTH + INTERWIDTH + Node->LabelWidth;
  33.                 Top        = Node->Top + (Node->Height - GlyphHeight) / 2;
  34.  
  35.                 break;
  36.  
  37.             case PLACE_ABOVE:
  38.  
  39.                 Left    = Node->Left + (Node->Width - Node->LabelWidth) / 2 + INTERWIDTH + Node->LabelWidth;
  40.                 Top        = Node->Top - (GlyphHeight + INTERHEIGHT);
  41.  
  42.                 break;
  43.  
  44.             case PLACE_BELOW:
  45.  
  46.                 Left    = Node->Left + (Node->Width - Node->LabelWidth) / 2 + INTERWIDTH + Node->LabelWidth;
  47.                 Top        = Node->Top + Node->Height + INTERHEIGHT;
  48.  
  49.                 break;
  50.         }
  51.  
  52.         LTP_PrintLabel(Handle,Node,Left,Top);
  53.     }
  54. }
  55.  
  56. VOID
  57. LTP_DrawGroup(LayoutHandle *Handle,ObjectNode *Group)
  58. {
  59.     ObjectNode *Node;
  60.     ULONG page;
  61.     LONG i;
  62.  
  63.     if(Group->Label || Group->Special.Group.Frame || Group->Special.Group.FrameType == FRAMETYPE_Label)
  64.         LTP_DrawGroupLabel(Handle,Group);
  65.     else
  66.     {
  67.         if(Group->Special.Group.FrameType == FRAMETYPE_Tab)
  68.             LTP_DrawGroupFrame(Handle,Group);
  69.     }
  70.  
  71.     SCANPAGE(Group,Node,page)
  72.     {
  73.         switch(Node->Type)
  74.         {
  75.             case BLANK_KIND:
  76.  
  77.                 break;
  78.  
  79. #ifdef OLD_STYLE_DEFAULT_KEY
  80.             case BUTTON_KIND:
  81.  
  82.                 if(Handle->ReturnKey == Node)
  83.                     LTP_DrawBevelBox(Handle,Node);
  84.  
  85.                 break;
  86. #endif
  87. #ifdef DO_GAUGE_KIND
  88.             case GAUGE_KIND:
  89.             {
  90.                 LONG Percent = Node->Current;
  91.  
  92.                 Node->Current = 0;
  93.  
  94.                 LTP_DrawGauge(Handle,Node,Percent,TRUE);
  95.  
  96.                 break;
  97.             }
  98. #endif
  99.             case PALETTE_KIND:
  100.  
  101.                 if(Node->Special.Palette.UsePicker)
  102.                     LTP_DrawPalette(Handle,Node);
  103.  
  104.                 break;
  105.  
  106.             case GROUP_KIND:
  107.  
  108.                 if(Node->Label)
  109.                     LTP_DrawGroupLabel(Handle,Node);
  110.  
  111.                 LTP_DrawGroup(Handle,Node);
  112.  
  113.                 break;
  114.  
  115.             case XBAR_KIND:
  116.             {
  117.                 LONG Top = Node->Top + ((Node->Height + 1) / 2) - 1;
  118.                 struct RastPort *RPort = &Handle->RPort;
  119.  
  120.                 if(Node->Special.Bar.FullSize)
  121.                 {
  122.                     LTP_SetAPen(RPort,Handle->ShadowPen);
  123.                     LTP_DrawLine(RPort,Handle->Window->BorderLeft,Top,Handle->Window->Width - (Handle->Window->BorderRight + 1),Top);
  124.  
  125.                     LTP_SetAPen(RPort,Handle->ShinePen);
  126.                     LTP_DrawLine(RPort,Handle->Window->BorderLeft,Top + 1,Handle->Window->Width - (Handle->Window->BorderRight + 1),Top + 1);
  127.                 }
  128.                 else
  129.                 {
  130.                     LONG Room;
  131.  
  132.                     if(Node->Special.Bar.Parent->Label)
  133.                         Room = 2 * Handle->GlyphWidth;
  134.                     else
  135.                         Room = 0;
  136.  
  137.                     LTP_SetAPen(RPort,Handle->ShadowPen);
  138.                     LTP_PolyDraw(RPort,3,
  139.                         Node->Special.Bar.Parent->Left + Room,Top + 1,
  140.                         Node->Special.Bar.Parent->Left + Room,Top,
  141.                         Node->Special.Bar.Parent->Left + Node->Special.Bar.Parent->Width - 1 - 1 - Room,Top);
  142.  
  143.                     LTP_SetAPen(RPort,Handle->ShinePen);
  144.                     LTP_PolyDraw(RPort,3,
  145.                         Node->Special.Bar.Parent->Left + Room + 1,Top + 1,
  146.                         Node->Special.Bar.Parent->Left + Node->Special.Bar.Parent->Width - 1 - Room,Top + 1,
  147.                         Node->Special.Bar.Parent->Left + Node->Special.Bar.Parent->Width - 1 - Room,Top);
  148.                 }
  149.  
  150.                 break;
  151.             }
  152.  
  153.             case YBAR_KIND:
  154.             {
  155.                 LONG Left = Node->Left + ((Node->Width + 1) / 2) - 1,Room;
  156.                 struct RastPort *RPort = &Handle->RPort;
  157.  
  158.                 if(Node->Special.Bar.Parent->Label)
  159.                     Room = Handle->GlyphHeight + Handle->InterHeight;
  160.                 else
  161.                     Room = 0;
  162.  
  163.                 LTP_SetAPen(RPort,Handle->ShadowPen);
  164.                 LTP_PolyDraw(RPort,3,
  165.                     Left + 1,    Node->Special.Bar.Parent->Top + Room,
  166.                     Left,        Node->Special.Bar.Parent->Top + Room,
  167.                     Left,        Node->Special.Bar.Parent->Top + Node->Special.Bar.Parent->Height - 1 - 1 - Room);
  168.  
  169.                 LTP_SetAPen(RPort,Handle->ShinePen);
  170.                 LTP_PolyDraw(RPort,3,
  171.                     Left + 1,    Node->Special.Bar.Parent->Top + Room + 1,
  172.                     Left + 1,    Node->Special.Bar.Parent->Top + Node->Special.Bar.Parent->Height - 1 - Room,
  173.                     Left,        Node->Special.Bar.Parent->Top + Node->Special.Bar.Parent->Height - 1 - Room);
  174.  
  175.                 if((Handle->AspectY + Handle->AspectX - 1) / Handle->AspectX >= 2)
  176.                 {
  177.                     LTP_SetAPen(RPort,Handle->ShadowPen);
  178.                     LTP_DrawLine(RPort,    Left - 1,    Node->Special.Bar.Parent->Top + Room,
  179.                                 Left - 1,    Node->Special.Bar.Parent->Top + Node->Special.Bar.Parent->Height - 1 - Room);
  180.  
  181.                     LTP_SetAPen(RPort,Handle->ShinePen);
  182.                     LTP_DrawLine(RPort,    Left + 2,    Node->Special.Bar.Parent->Top + Room,
  183.                                 Left + 2,    Node->Special.Bar.Parent->Top + Node->Special.Bar.Parent->Height - 1 - Room);
  184.                 }
  185.  
  186.                 break;
  187.             }
  188.  
  189.             case FRAME_KIND:
  190.  
  191.                 if(Node->Special.Frame.DrawBox)
  192.                     LTP_DrawBevelBox(Handle,Node);
  193.  
  194.                 if(Node->Special.Frame.RefreshHook)
  195.                 {
  196.                     RefreshMsg Message;
  197.  
  198.                     Message.ID        = Node->ID;
  199.                     Message.Left    = Node->Left;
  200.                     Message.Top        = Node->Top;
  201.                     Message.Width    = Node->Width;
  202.                     Message.Height    = Node->Height;
  203.  
  204.                     if(Node->Special.Frame.DrawBox)
  205.                     {
  206.                         Message.Left    += 4;
  207.                         Message.Top        += 2;
  208.                         Message.Width    -= 8;
  209.                         Message.Height    -= 4;
  210.                     }
  211.  
  212.                     CallHookPkt(Node->Special.Frame.RefreshHook,Handle,&Message);
  213.                 }
  214.  
  215.                 // FALL THROUGH TO...
  216.  
  217.             case BOOPSI_KIND:
  218.  
  219.                 // FALL THROUGH TO...
  220.  
  221.             case POPUP_KIND:
  222.  
  223.                 // FALL THROUGH TO...
  224.  
  225.             case TAPEDECK_KIND:
  226.  
  227.                 LTP_DrawObjectLabel(Handle,Node);
  228.                 break;
  229.  
  230.             case MX_KIND:
  231.  
  232.                 if(Node->Label && !V39)
  233.                     LTP_PrintLabel(Handle,Node,Node->Left,Node->Top + (Node->Height - Handle->GlyphHeight) / 2 + 1);
  234.  
  235.                 break;
  236.  
  237.             case LISTVIEW_KIND:
  238.             {
  239.                 struct RastPort *RPort = &Handle->RPort;
  240.  
  241.                 if(Node->Special.List.ExtraLabels)
  242.                 {
  243.                     LTP_SetPens(RPort,Handle->TextPen,0,JAM1);
  244.  
  245.                     for(i = 0 ; Node->Special.List.ExtraLabels[i] ; i++)
  246.                     {
  247.                         LONG Len = strlen(Node->Special.List.ExtraLabels[i]);
  248.  
  249.                         LTP_PrintText(RPort,Node->Special.List.ExtraLabels[i],Len,Node->Left - (TextLength(RPort,Node->Special.List.ExtraLabels[i],Len) + INTERWIDTH),Node->Top + 2 + i * Handle->GlyphHeight);
  250.                     }
  251.                 }
  252.  
  253.                 if(Node->Label)
  254.                 {
  255.                     if(Node->LabelPlace == PLACE_ABOVE && Node->Special.List.FlushLabelLeft)
  256.                     {
  257.                         struct TextFont *Font = NULL,*OldFont;
  258.  
  259.                         if(Node->Special.List.TextAttr)
  260.                         {
  261.                             if(Font = LTP_OpenFont(Node->Special.List.TextAttr))
  262.                             {
  263.                                 OldFont = RPort->Font;
  264.  
  265.                                 SetFont(RPort,Font);
  266.                             }
  267.                             else
  268.                                 break;
  269.                         }
  270.  
  271.                         LTP_PrintLabel(Handle,Node,Node->Left + 2 + INTERWIDTH + Node->LabelWidth,Node->Top - (Handle->GlyphHeight + INTERHEIGHT));
  272.  
  273.                         if(Font)
  274.                         {
  275.                             SetFont(RPort,OldFont);
  276.  
  277.                             CloseFont(Font);
  278.                         }
  279.                     }
  280.                     else
  281.                     {
  282.                         if(Node->Special.List.TextAttr)
  283.                             LTP_DrawObjectLabel(Handle,Node);
  284.                     }
  285.                 }
  286.  
  287.                 break;
  288.             }
  289.  
  290.             case BOX_KIND:
  291.             {
  292.                 struct RastPort *RPort = &Handle->RPort;
  293.  
  294.                 Node->Special.Box.Parent = Group;
  295.  
  296.                 if(Node->Special.Box.DrawBox)
  297.                     LTP_DrawBevelBox(Handle,Node);
  298.  
  299.                 for(i = 0 ; i < Node->Lines ; i++)
  300.                 {
  301.                     if(Node->Special.Box.Labels && Node->Special.Box.Labels[i])
  302.                     {
  303.                         LONG Len = strlen(Node->Special.Box.Labels[i]);
  304.  
  305.                         LTP_SetPens(RPort,Handle->TextPen,0,JAM1);
  306.                         LTP_PrintText(RPort,Node->Special.Box.Labels[i],Len,Node->Left - (TextLength(RPort,Node->Special.Box.Labels[i],Len) + INTERWIDTH),Node->Top + 2 + i * Handle->GlyphHeight);
  307.                     }
  308.  
  309.                     LTP_PrintBoxLine(Handle,Node,i);
  310.                 }
  311.  
  312.                 break;
  313.             }
  314.         }
  315.     }
  316. }
  317.